<?php
/**
 * 文章列表
 *
 */
function & li($page_size = ADM_PAGESIZE) {
    global $_TABLES, $class_var, $cata_info, $timestamp,$G_admin_session_key;

    $view_var   = array();
    $tbl_main   = $_TABLES['company'];

    $conn   = & get_db_conn();

    $where      = 'WHERE 1 ';
    
    // 关键字
    $key    = trim(@$_GET['key']);
    if($key != '') $where  .= "AND (name LIKE '%$key%')";

    // 审核
    $display = @(int)$_GET['display'];
    if($display == 1) {
        $where  .= "AND display = 1 ";
    } elseif($display == 2) {
        $where  .= "AND display = 0 ";
    }

    $is_ad  = @$_GET['is_ad'];
    if($is_ad == 1) {
        // 发布时间处理开始
        $begin_date = @$_GET['begin_date'];
        $end_date   = @$_GET['end_date'];
        if($begin_date == '') {
            $begin_date   = 0;
        } else {
            $tmp    = explode('-', $begin_date);
            $begin_date = mktime(0 ,0, 0,$tmp[1] ,$tmp[2], $tmp[0]);
        }
        if($end_date == '') {
            $end_date   = $timestamp;
        } else {
            $tmp        = explode('-', $end_date);
            $end_date   = mktime(23 ,59, 59,$tmp[1] ,$tmp[2], $tmp[0]);
        }
        $where .= "AND (pub_time >= '$begin_date' AND pub_time <= '$end_date' ) ";
    }


    // 分页处理开始
    $csql   = "SELECT COUNT(*) AS rs_count FROM $tbl_main $where";
    $rs     = $conn->GetOne($csql);


    $record_total   = @(int)$rs;
    $page_total     = ceil($record_total/$page_size);

    $page   = @(int)$_GET['page'];
    if($page < 1) $page = 1;
    if($page > $page_total && $page_total > 0) $page = $page_total;
    $offset = ($page - 1) * $page_size;
    $limit  = "LIMIT $offset, $page_size";

    $view_var['record_total']   = $record_total;
    $view_var['page_total']     = $page_total;
    $view_var['page']           = $page;
    $view_var['page_size']      = $page_size;
    // 分页处理完毕


    // 列表处理开始
    $order_by   = trim(@$_GET['orderby']);
    $order_desc = @(int)$_GET['desc'];
    
    $order_by_q  = substr($order_by,0,5);
    $order_by_h  = substr($order_by,5);

    if($order_by_q   == 'flag_') {
        $order_by   = $order_by_h;
    }
    $select_param   = '';
    $str_order_by   = '';
    if($order_by != '') {
        if($order_by > 0) {
            $order_desc = ($order_desc!=1)?'DESC':'ASC';
            $orderfield = 'f' . $order_by;
            $select_param   = ",((`flag` & $order_by ) = $order_by) AS $orderfield";
            $str_order_by   = "{$orderfield} {$order_desc},";
        } else {
            $order_desc = ($order_desc!=1)?'ASC':'DESC';
            $str_order_by = "`{$order_by}` {$order_desc}, ";
        }
    }


    $order  = "";
    if($cata_info['cata_type'] == 1) {
        $order  = "ORDER BY $str_order_by pub_date ASC, id ASC";
    } else {
        $order  = "ORDER BY $str_order_by id DESC";
    }

    $sql    = "SELECT * FROM $tbl_main $where $order ";
    //echo $sql;
    $rs = & $conn->PageExecute($sql,$page_size,$page);
    $view_var['record'] = $rs->GetRows();
    return $view_var;
}

function & read($id = 0) {
    global $_TABLES, $timestamp, $mod, $G_admin_session_key, $G_cfg, $G_big_integer;

    $view_var   = array();
    $tbl_main   = $_TABLES['company'];
    
    if($id > 0) {
        $conn       = & get_db_conn();
        $view_var   = $conn->GetRow("SELECT * FROM $tbl_main WHERE id = $id");
    } else {
		$pub_userid    = $_SESSION[$G_admin_session_key]['uid'];
        $pub_username  = $_SESSION[$G_admin_session_key]['username'];
        $pub_realname  = $_SESSION[$G_admin_session_key]['realname'];
        // 看用户是否有审核权限
        $chk_userid    = $_SESSION[$G_admin_session_key]['uid'];
        $chk_username  = $_SESSION[$G_admin_session_key]['username'];
        $chk_realname  = $_SESSION[$G_admin_session_key]['realname'];
        $view_var   = array(
                'hits'    => 0,
                'display' => $G_cfg['article_cfg']['article_display_default'],
                'pub_userid'      => $pub_userid,
              'pub_username'    => $pub_username,
              'pub_realname'    => $pub_realname,
              'pub_time'        => $timestamp,
              'createtime'     => $timestamp,
              'modifytime'      => $timestamp,
              'chk_userid'      => $chk_userid,
              'chk_username'    => $chk_username,
              'chk_realname'    => $chk_realname,
              'chk_time'        => $timestamp,            
              );
    }
    return $view_var;
}


/**
 * @description
 *  文章详细内容，
 *  获取参数，验证参数，初始化参数
 * @author
 *  hotgun@163.com
 *
 * @param
 *  (integer)$upload 是否包含并处理上传部分，如果是单独审核的就不需要包含这块，
 * @return 
 *  (array)修改和添加能使用的数组
 */
function & request($upload = 1) {
    global $action, $timestamp, $G_big_integer, $_TABLES;
    $data   = $_POST['article'];
    $data['display']  = @(int)$data['display']; // 审核
    if($data['pub_time']) {
        $data['pub_time']   = strtotime($data['pub_time']);
    } else {
        $data['pub_time']   = $timestamp;
    }

    // 处理单双引号等问题
    $data = post_pre_process($data);

    // 过滤HTML内容中被php转义后的字符 
    // 去掉双引号前的转移符，将转义后的单引号转换成&#39;
    if(isset($data['content']))
	$data['content']    = str_replace("\\\"", "\"", str_replace("\\'", "&#39;", $data['content']));

    $rule = array();
    $def_err = array();
    if($upload == 1) {
        $rule   = array(
            'name' => 'i_string|len:1:255', 
            );

        // 验证正确性
        $def_err= array(
            'name' => '“名字”必须填写，且长度必须在1～255个字符之间！', 
            );
    }
    
    $result = data_validator($data, $rule, $def_err);
    if($result === true) {
        // 其他逻辑错误检验
    } else {
        foreach($result as $v) {
            $GLOBALS['ERR']->AddError(_ERROR_BUSINESS, 
                        $v, 
                        __FILE__,
                        __LINE__);
        }
    }
    if($GLOBALS['ERR']->Count > 0) {
        return false;
    } else {
        return $data;
    }
}

function not_samerecord($uid, $title, $modify = 0) {
    global $_TABLES;

    $tbl_main   = $_TABLES['company'];
    $conn       = & get_db_conn();
    $where      = '';
    if($modify){
        $where=' AND id<>'.$modify;
    }
    $rs = $conn->GetRow("SELECT COUNT(*) AS rs_count FROM $tbl_main WHERE title = '$title' AND uid = '$cid' $where ");
    if($rs['rs_count'] > 0) {
        $GLOBALS['ERR']->AddError(_ERROR_BUSINESS, 
                "系统中已经存在标题为<FONT COLOR=\"red\">{$title}</FONT>的通知，无法当前操作！", 
                __FILE__,
                __LINE__);
        return false;
    }
    return true;
}


/**
 * @description
 *  添加文章内容
 * @author
 *  hotgun@163.com
 *
 * @return 
 *  (array)供主控部分使用的返回数据
 */
function add() {
    global $_TABLES, $timestamp, $mod, $class_var, $G_admin_session_key, $G_cfg;

    $tbl_article        = $_TABLES['company'];

    $result = & request();
    if($result !== false) {
        $conn   = & get_db_conn();
        if(not_samerecord($result['uid'], $result['title'])) {
            // 如果没有同名纪录
            // 创建者/审核者等数据
            $result['pub_userid']   = $_SESSION[$G_admin_session_key]['uid'];
            $result['pub_username'] = $_SESSION[$G_admin_session_key]['username'];
            $result['pub_realname'] = $_SESSION[$G_admin_session_key]['realname'];
            if($conn->AutoExecute($tbl_article,$result,'INSERT')) {
                $id    = $conn->Insert_ID();
                $re = array('id'=>$id);
                return $re;
            }
        }
    }
    return false;
}


function modify() {
    global $_TABLES, $timestamp, $class_var, $G_admin_session_key;
    $tbl_article        = $_TABLES['company'];
    $result = & request();
    if($result !== false) {
        $conn   = & get_db_conn();
        unset($result['pub_hour']);
        unset($result['pub_min']);
        unset($result['pub_sec']);
        // 先查看是否有同名记录
        if(not_samerecord($result['uid'], $result['name'], $result['id'])) {
            if($conn->AutoExecute($tbl_article,$result,'UPDATE', 'id=' . $result['id'] )) {
                // 返回到控制器的内容
                $re = array('id'=>$result['id']);
                return $re;
            }
        }
    }
}

function check_batch($check) {
    global $_TABLES, $timestamp, $class_var, $G_admin_session_key;
    $tbl_article        = $_TABLES['company'];
    if(@(int)$check < 1) {
        $check  = 0;
        $checklang  = '取消审核';
    } else {
        $check  = 1;
        $checklang  = '通过审核';
    }

    $item_id    = array_join_comma($_POST['item_id']);
    if($item_id != '') {
        $conn   = & get_db_conn();

        $update_sql = "update $tbl_article SET 
            $sql_append
            display = $check 
            WHERE id IN ($item_id)";
        if($conn->Execute($update_sql)) {
            js_success('指定文章' . $checklang . '成功！');
        }
    }
    exit();
}

/**
 * @description
 *  审核单篇文章
 * 
 * @author
 *  hotgun@163.com
 */
function check() {
    global $_TABLES, $timestamp, $class_var, $G_admin_session_key;

    $tbl_article        = $_TABLES['company'];

    $result = request(0);
    if($result !== false) {
        $conn   = & get_db_conn();

        if(@(int)$result['display'] == 1) {
            
        } else {
            $result['display'] = 0;
        }
        if($conn->AutoExecute($tbl_article,$result,'UPDATE', 'id=' . $result['id'] )) {
            return $result['id'];
        }
    }
}

function del() {
    global $_TABLES, $cfg_cache;
    $tbl_article = $_TABLES['company'];

    $deltype    = trim(@$_POST['deltype']);
    if($deltype == 'all') {
        // 删除POST传递过来的 item_id 
        // 批量删除
        $str_in = array_join_comma($_POST['item_id']);
    } else {
        // get传递过来的删除 单条删除
        $item_id= @(int)$_GET['item_id'];
        $str_in = $item_id;
    }
$conn   = & get_db_conn();
    if($str_in != '') {
        $sql    = "DELETE FROM $tbl_article 
                    WHERE id IN ({$str_in}) ";
        if($conn->Execute($sql)) {
			js_success('删除指定文章成功！');
        }
    }
}



/**
 * 分析上传的文件数组，构造sql
 *
 *
 *
 */
function parse_up_img($img, $var, $oldimg = null, $modifyimg = null) {
    if(is_array($img)) {
        if(array_key_exists('aid', $img)) {
            $img_aid= $img['aid'];
            $imgs   = $img['aid'];
            $img    = $img['destfile'];
        } else {
            $tmp_small_images = '';
            $find_default = false;
            foreach($img as $v) {
                $tmp_small_images .= $v['aid'] . ',';
                if($v['default']) {
                    $tmp_small_image_aid = $v['aid'];
                    $tmp_small_image     = $v['destfile'];
                    $find_default       = true;
                }
            }
            $imgs   = $tmp_small_images;
            if(!$find_default) {
                $img_aid= $img[0]['aid'];
                $img    = $img[0]['destfile'];
            } else {
                $img_aid= $tmp_small_image_aid;
                $img    = $tmp_small_image;
            }
        }
    } else {
        $img    = '';
        $img_aid= 0;
        $imgs   = '';
    }
    return array(
        'update_f'  => "$var, {$var}_aid, {$var}s, ",       // insert into 里的字段
        'update_v'  => "'$img', '$img_aid', '$imgs', ",     // insert into 里的值
        'all_aid'   => $imgs,
        'update'    => "$var = '$img', {$var}_aid = '$img_aid', {$var}s = '$imgs', ",   // update 里的各值
        );
}


// 同步图片
function syn_article_images($aid, $images, $tbl=array()) {
    global $_TABLES, $action;

    $tbl_article        = $_TABLES['article'];
    $tbl_attachments    = $_TABLES['attachments'];

    // 重构 $small_image 和 $big_image
    // 统一一张图片和多张图片的数组结构
    $all_up_image   = '';
    foreach($images as $k => $v) {
        $images[$k] = parse_image_var($v);
        $tmp    = parse_up_img($v, $k);
        $all    = $tmp['all_aid'];
        $all_up_image  .= $all . ',';
    }
    $all_up_image   = conv_valid_instr($all_up_image);

    if($all_up_image != '') {
        $conn   = & get_db_conn();
        // 为刚才上传的文件记录修改上传模块和文章ID字段，记录该文件被用于做什么
        $sql    = "UPDATE $tbl_attachments SET 
                    item_id = '$aid'
                    WHERE aid IN ($all_up_image) ";
        $conn->Execute($sql);
    }


    if($action == 'modify' || substr($action, strrpos($action, '.')+1) == 'modify') {
        foreach($images as $k => $v) {
            $modimg = update_modimg_att($k);
            $images[$k] = empty($v) ? $modimg : array_merge($modimg, $v);
        }
    }

    foreach($images as $k => $v) {
        update_addimg_att($v, $k, $aid, $tbl);
    }





    $flagv  = 2;   // 图片标志
    // 在这里分析如果上传了小图片的文章，设置属性flag加上图片新闻标志，否则去掉
    $conn   = & get_db_conn();
    $ars = $conn->GetRow("SELECT aid, small_image_aid, flag FROM $tbl_article WHERE aid = '$aid' ");
    if($ars) {

        if(@(int)$ars['small_image_aid'] > 0 || (($ars['flag']&$flagv)==$flagv)) {
            // 如果上传了缩略图，或者明确指定了该文章为图片文章
            $flag = ($ars['flag'] | $flagv);
        } else {
            $flag = ($ars['flag'] | $flagv) ^ $flagv;
        }
        $conn->Execute("UPDATE $tbl_article SET flag='$flag' WHERE aid = '$aid' ");
    }
}

function parse_image_var($var) {
    if(is_array($var)) {
        if(@(int)$var['aid'] > 0) {
            return array($var);
        }
    }
    return $var;
}

function update_addimg_att($images, $var, $item_id = 0, $tbl = array()) {
    global $_TABLES, $timestamp, $mod, $action, $class_var, $G_big_integer;


    if($tbl['tbl'] == '') $tbl['tbl'] = $_TABLES['article'];
    if($tbl['pk'] == '') $tbl['pk'] = 'aid';
    $tbl_attachments    = $_TABLES['attachments'];

    $conn   = & get_db_conn();
    if($action == 'modify') {
        // 设置所有的该$item_id的默认为空
        $sql    = "UPDATE $tbl_attachments SET item_default = 0 
                        WHERE item_id = $item_id
                          AND upmod = '$mod'
                          AND upvar = '$var'";
        $conn->Execute($sql);
    }
    // 设置默认图

    //print_r($images);
    $default    = @(int)$_POST['default_' . $var];
    //echo " \$default = $default<br /> ";
    //exit();
    if($default <= 0) $default = 1;


    $db_image       = '';
    $db_image_aid   = 0;
    $db_images      = '';
    if(is_array($images) && sizeof($images) > 0) {
        if(@(int)$images['aid'] > 0) {
            $default_aid    = $images['aid'];
        } else {
            $default_aid    = $images[$default-1]['aid'];
        }

        //echo "default count  = " . ($default-1) . '<BR />';
        $db_image   = $images[$default-1]['destfile'];
        $db_image_aid   = $default_aid;
        /*
        print_r($images);
        echo "\$db_image = $db_image <br />";
        echo "\$db_image_aid = $db_image_aid <br />";
        exit();
        */



        // 设置默认图片
        $sql    = "UPDATE $tbl_attachments SET item_default = 1 WHERE aid = $default_aid";
        //echo $sql;
        $conn->Execute($sql);


        // 这里需要设置“item_id=0”
        // 从$tbl_attachments中找出所有的文件
        // 从中剔除 $images 中没有的
        $sql    = "SELECT aid, fileurl FROM $tbl_attachments WHERE item_id = $item_id AND upmod = '$mod' AND upvar = '$var'";
        $rs = $conn->Execute($sql);
        $rs = $rs->GetRows();

        $delaid = '';
        foreach($rs as $item) {
            $thisaid    = @(int)$item['aid'];
            $find       = false;
            foreach($images as $v) {
                $post_aid = @(int)$v['aid'];
                if($post_aid == $thisaid) {
                    $find = true;
                    break;
                }
            }
            if($find) {
                // 如果找到了，需要构造images字段
                $db_images .= $thisaid . ',';
            } else {
                // 没有找到，需要删除
                $delaid .= $thisaid . ',';
            }
        }
        // 如果是修改，当前台删除了一些图片以后，不需要判断是否修改，因为新增$delaid始终为空
        if($delaid != '') {
            $delaid = substr($delaid, 0, strlen($delaid)-1);
            $sql    = "UPDATE $tbl_attachments SET item_id = 0 WHERE aid IN ($delaid)";
            $conn->Execute($sql);
        }
    } else {
        // 删除了所有的图片
        $sql    = "update $tbl_attachments SET item_id = 0 WHERE item_id = $item_id AND upmod = '$mod' AND upvar = '$var'";
        $conn->Execute($sql);
    }

    // 更新文章字段
    // 这样做好点，虽然大小图分两次处理，但是可以随时增加“图片”字段
    $sql    = "UPDATE {$tbl['tbl']} SET {$var} = '$db_image', {$var}_aid = '$db_image_aid', {$var}s = '$db_images' WHERE {$tbl['pk']} = $item_id ";
    $conn->Execute($sql);
    //echo($sql);
}

function update_modimg_att($var) {
    global $_TABLES, $action, $G_big_integer;

    $tbl_attachments    = $_TABLES['attachments'];


    $arr = array();
    $tmp = @$_POST[$var . '_modaid'];
    if(!is_array($tmp)) return array();
    $icount = 0;
    $sql    = '';
    $conn   = & get_db_conn();
    foreach($tmp as $v) {
        $v  = @(int)$v;
        if($v > 0) {
            $description    = trim($_POST[$var . '_moddescription'][$icount]);
            $item_order     = @(int)$_POST[$var . '_modorder'][$icount];
            if($item_order <=0 || $item_order >= $G_big_integer) {
                $item_order = $G_big_integer;
            }
            $arr[]  = array(
                'aid'           => $v,
                'destfile'      => trim($_POST[$var . '_fileurl'][$icount]),
                'item_order'    => $item_order,
                'description'   => $description,
                );
            // 更新描述和排序
            $sql    = "UPDATE $tbl_attachments SET description = '$description', item_order='$item_order' WHERE aid = '$v'";
            $conn->Execute($sql);
        }
        $icount ++;
    }
    return $arr;
}

function get_html_img_record($in, $input_name) {
    global $_TABLES, $G_web_upload, $G_big_integer;


    $str= '';
    $icount = 1;
    if($in != '') {
        $conn   = & get_db_conn();
        // 如果传递过来的变量中有数据
        $in = $in . '0';
        $sql    = "SELECT * FROM " . $_TABLES['attachments'] . " WHERE aid IN ( $in ) 
                    ORDER BY item_order ASC, aid ASC ";
        $rs = $conn->Execute($sql);
        $rs = $rs->GetRows();
        foreach($rs as $items) {
            $fileid     = $items['aid'];
            $filename   = $items['filename'];
            $db_fileurl = $items['fileurl'];
            $fileurl    = $G_web_upload . $db_fileurl;
            $description= $items['description'];
            $chk_this   = $items['item_default'] == 1 ? 'checked' : '';
            $item_order = @(int)$items['item_order'];
            if($item_order <= 0 || $item_order >= $G_big_integer) $item_order = '';
            $str   .= <<<EOT
    <TR>
        <TD><SPAN id="{$input_name}_{$icount}">
    [<a href="javascript:void(0);" onclick="return del_upload_file(this.parentNode.parentNode.parentNode.rowIndex, '$input_name');">删除</a>]&nbsp;&nbsp;<INPUT TYPE="radio" NAME="default_{$input_name}" ID="default_{$input_name}_{$icount}" value="$icount" onclick="return default_img(this, '$fileurl', '$input_name');" $chk_this> 
    <label for="default_{$input_name}_{$icount}">默认</label>&nbsp;&nbsp;
    <a href="$fileurl" target="_blank">$filename</a>

        <INPUT TYPE="hidden" NAME="{$input_name}_fileurl[]" value="$db_fileurl">

        </SPAN><input type="hidden" name="{$input_name}_modaid[]" value="$fileid"></TD>
        <TD><input type="text" name="{$input_name}_modorder[]" id="{$input_name}_modorder[]" value="$item_order" size="3" class="text"></TD>
        <TD><input type="text" name="{$input_name}_moddescription[]" id="{$input_name}_moddescription[]" value="$description" size="12" class="text"></TD>
    </TR>
EOT;
            $icount ++;
        }
    }

    // 构造整个上传表格
    $str  = <<<EOT
<TABLE border="0" cellpadding="2" cellspacing="0" id="{$input_name}_table" width="100%" style="width:98%">
<TR>
    <TD width="240">上传图片</TD>
    <TD>排序</TD>
    <TD>描述</TD>
</TR>
$str
<TR>
    <TD><SPAN id="{$input_name}_$icount"></SPAN><INPUT TYPE="file" NAME="{$input_name}[]" class="text" size="12" onchange="upload_onchange(this)"></TD>
    <TD><input type="text" name="{$input_name}_order[]" id="{$input_name}_order[]" value="" size="3" class="text"></TD>
    <TD><input type="text" name="{$input_name}_description[]" id="{$input_name}_description[]" value="" size="12" class="text"></TD>
</TR>
</TABLE>
EOT;

    // 初始化当前行数计数器
    $str   .= <<<EOT
<SCRIPT LANGUAGE="JavaScript">
<!--
var n_{$input_name}_table_trnum = {$icount};
var n_{$input_name}_table_anum  = {$icount};
//-->
</SCRIPT>
EOT;
    return $str;
}
function echo_html_img_js() {
    /** 
     * var file_name = file_path.substr(file_path.lastIndexOf('\\\\')+1);
     * 在html页面上是
     * var file_name = file_path.substr(file_path.lastIndexOf('\\')+1);
     * 但是在php字符串中反斜线要转义，所以多加了一个。
     */
    echo <<<EOT
<SCRIPT LANGUAGE="JavaScript">
<!--
function upload_onchange(ofile) {
    var upload_var= ofile.name;
    ofile.style.display = 'none';
    upload_var = upload_var.substr(0,upload_var.length-2);

    var file_path = ofile.value;
    file_path = file_path.replace(/\\\\/g, '/');
    var file_name = file_path.substr(file_path.lastIndexOf('/')+1);


    eval('o_' + upload_var + '_table = GE("'+upload_var+'_table");');
    eval('if(typeof(n_' + upload_var + '_table_trnum)=="undefined")n_' + upload_var + '_table_trnum=1');
    eval('var trnum = n_' + upload_var + '_table_trnum');
    eval('var anum = n_' + upload_var + '_table_anum');
    eval('var row = o_' + upload_var + '_table.insertRow()');

    eval('var chk_default_this = trnum == 1 ? " checked" : ""; ');

    var str='[<a href="javascript:void(0);" onclick="return del_upload_file(this.parentNode.parentNode.parentNode.rowIndex, \'' + upload_var + '\');">删除</a>]&nbsp;&nbsp;'+
            '<INPUT TYPE="radio" NAME="default_' + upload_var + '" ID="default_' + upload_var + '_' + trnum + '" value="' + trnum + '" onclick="return default_img(this, \'file:///'+file_path+'\', \''+upload_var+'\');" ' + chk_default_this + '>' + 
            ' <label for="default_'+upload_var+'_' + trnum + '">默认</label>&nbsp;&nbsp;' + 
            ' <a href="file:///'+file_path+'" target="_blank">'+file_name+'</a>';
    //alert(str);
    //eval('alert('+trnum+');');
    eval('GE("'+upload_var+'_'+anum+'").innerHTML=str;');

    cell0 = row.insertCell();
    cell1 = row.insertCell();
    cell2 = row.insertCell();

    cell0.innerHTML = '<SPAN id="'+upload_var+'_'+(anum+1)+'"></SPAN>' + 
                        '<input type="file" name="' + upload_var + '[]" value="" class="text" size="12" onchange="upload_onchange(this)">';
    cell1.innerHTML = '<input type="text" name="' + upload_var + '_order[]" value="" size="3" class="text">'
    cell2.innerHTML = '<input type="text" name="' + upload_var + '_description[]" value="" size="12" class="text">'


    eval('n_' + upload_var + '_table_trnum ++;');
    eval('n_' + upload_var + '_table_anum ++;');
}

function del_upload_file(id, upload_var) {
    eval('o_del_table=GE("'+upload_var+'_table");o_del_table.deleteRow('+id+');n_'+upload_var+'_table_trnum --;');
}
function default_img(chkobj, img, upload_var) {
    if(chkobj.checked) {
        eval('GE("obj_'+upload_var+'").src="'+img+'";');
    }
}
//-->
</SCRIPT>

EOT;
}

function content_param($aid, $param) {
    // 暂不处理自定义字段
}
?>